let marbleRaceLevel9_4 = {
	name: 'Game 9 Level 4',
	id: '9_4',
	type: 'value',
	valueBonus: 0,
	scoreBonus: 5,
	valueThreshold: 0,
	minPass: 1,
	objects: [
		// Portals
		{
			type: 'object',
			shape: 'rect',
			color: '@b',
			toPortal: 'a',
			x: 140,
			y: 540 - 10,
			width: 120,
			height: 20,
			valueBonus: 1
		},
		{
			type: 'text',
			content: '+1',
			color: '@background',
			x: 140,
			y: 540 - 10
		},
		{
			type: 'object',
			shape: 'rect',
			color: '@a',
			toPortal: 'a',
			x: 260,
			y: 540 - 10,
			width: 120,
			height: 20,
			valueBonus: -1
		},
		{
			type: 'text',
			content: '−1',
			color: '@foreground',
			x: 260,
			y: 540 - 10
		},
		{
			type: 'object',
			shape: 'rect',
			color: '@goal',
			toPortal: 'goal',
			isGoal: true,
			x: 340,
			y: 540 - 10,
			width: 40,
			height: 20
		},
		{
			type: 'object',
			shape: 'rect',
			color: '@a',
			toPortal: 'a',
			x: 420,
			y: 540 - 10,
			width: 120,
			height: 20,
			valueMultiply: 5 / 6
		},
		{
			type: 'text',
			content: '÷1.2',
			color: '@foreground',
			x: 420,
			y: 540 - 10
		},
		{
			type: 'object',
			shape: 'rect',
			color: '@b',
			toPortal: 'a',
			x: 540,
			y: 540 - 10,
			width: 120,
			height: 20,
			valueBonus: 4
		},
		{
			type: 'text',
			content: '+4',
			color: '@background',
			x: 540,
			y: 540 - 10
		},
		{
			type: 'object',
			shape: 'circle',
			color: '@a',
			portalID: 'a',
			x: 340,
			y: 80,
			radius: 5
		},

		// Goal portal
		{
			type: 'object',
			shape: 'circle',
			color: '@goal',
			portalID: 'goal',
			x: 700,
			y: 80,
			radius: 5
		},

		// Obstacles

		// Borders
		{
			type: 'object',
			shape: 'rect',
			color: '@tertiary',
			x: 400,
			y: 0,
			width: 800,
			height: 120
		},
		{
			type: 'object',
			shape: 'rect',
			color: '@tertiary',
			x: 400,
			y: 600,
			width: 800,
			height: 120
		},
		{
			type: 'object',
			shape: 'rect',
			color: '@tertiary',
			x: 0,
			y: 300,
			width: 160,
			height: 600
		},
		{
			type: 'object',
			shape: 'rect',
			color: '@tertiary',
			x: 800,
			y: 300,
			width: 160,
			height: 600
		},
		{
			type: 'object',
			shape: 'rect',
			color: '@tertiary',
			x: 640,
			y: 300,
			width: 80,
			height: 600
		},

		// Marbles
		{
			type: 'marbles',
			x: 340,
			y: 80,
			launchTime: 3,
			launchRadius: 75,
			passX: 700,
			passY: 80,
			radius: 8,
			eliminatedRadius: 6,
			velocity: 5
		},
	]
}
{
	let cntI = 6
	for (let i = 0; i <= cntI; ++i) {
		let cntJ = 6
		for (let j = 0; j <= cntJ; ++j) {
			let x0 = 340 + (j * 2 - cntJ - .5) * 260 / (cntJ + 1)
			marbleRaceLevel9_4.objects.push({
				type: 'object',
				shape: 'rect',
				color: '@secondary',
				x: x0,
				y: 300 + (i - cntI * .5) * 50,
				width: 260 / (cntJ + 1),
				height: 10,
				onCollide: function (object, marbleID, engine) {
					let pos = engine.getPosition(object.body)
					if (pos[0] < x0 + 20)
						pos[0] += 40
					else
						pos[0] -= 40
					engine.setPosition(object.body, pos)

					let v = engine.getVelocity(engine.circleArray[marbleID])
					v[0] += engine.random(-2, 2)
					v[1] -= 2
					engine.setVelocity(engine.circleArray[marbleID], v)
				}
			})
		}
	}
}
marbleRaceLevels.push(marbleRaceLevel9_4)